<?php

namespace app\api\controller;

use app\api\service\CommonService;
use app\api\service\ExaminationService;
use app\api\validate\CommonValidate;

class Common extends Base
{
    protected $middleware = ['NotFoundMiddleware'];

    /**
     * 获取最新公告
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getNoticeNew()
    {
        list($code, $msg, $data) = CommonService::getNoticeNew();
        apiReturn($code, $msg, $data);
    }

    /**
     * 获取图片配置
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getImagesList()
    {
        if (($msg = CommonValidate::getImagesList($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = CommonService::getImagesList($this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 获取热门考题
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getHotExamination()
    {
        if (($msg = CommonValidate::getHotExamination($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = ExaminationService::getHotExamination($this->params);
        apiReturn($code, $msg, $data);
    }
}